﻿Imports System.Windows.Controls.Canvas

Public Class clsTooltip
    Inherits TextBox

    Protected m_Tooltip As ToolTip

    Public Sub New(ByVal tooltip As ToolTip)
        m_Tooltip = tooltip
        Background = Brushes.White
        TextAlignment = Windows.TextAlignment.Center
        TextWrapping = Windows.TextWrapping.Wrap
        FontWeight = FontWeights.Bold
        Focusable = True
        BorderThickness = New Thickness(2)
        Width = c_TooltipeWidth
        Visibility = Windows.Visibility.Hidden
    End Sub

    Public Sub Edit(Optional ByVal flag As Boolean = True)
        If flag Then
            Text = m_Tooltip.Content
            Visibility = Windows.Visibility.Visible
            Focus()
        Else
            Visibility = Windows.Visibility.Hidden
            m_Tooltip.Content = Text
        End If
    End Sub

    Private Sub shpLabel_LostFocus(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles Me.LostFocus
        Edit(False)
    End Sub

    Protected Sub shpLabel_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles Me.KeyDown
        If e.Key = Input.Key.Enter Then
            Edit(False)
        End If
    End Sub
End Class
